package org.jeecg.modules.wms.service;

import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.wms.entity.WmsOutboundAllocationPlan;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.wms.vo.OutboundAllocationResult;
import java.util.List;

/**
 * 出库分配方案服务接口
 */
public interface IWmsOutboundAllocationPlanService extends IService<WmsOutboundAllocationPlan> {
    
    /**
     * 自动分配出库方案
     * @param outboundId 出库单ID
     * @return 分配结果
     */
    OutboundAllocationResult autoAllocateOutbound(String outboundId);
    
    /**
     * 根据出库单ID查询分配方案
     * @param outboundId 出库单ID
     * @return 分配方案列表
     */
    List<WmsOutboundAllocationPlan> getByOutboundId(String outboundId);
    
    /**
     * 保存分配方案并更新库存预出库数量
     * @param outboundId 出库单ID
     * @param allocationPlans 分配方案列表
     * @return 是否成功
     */
    boolean saveAllocationPlansAndUpdateInventory(String outboundId, List<WmsOutboundAllocationPlan> allocationPlans);
    
    /**
     * 清除出库单的分配方案并释放预出库数量
     * @param outboundId 出库单ID
     * @return 是否成功
     */
    boolean clearAllocationPlansAndReleaseInventory(String outboundId);
    
    /**
     * 检查分配方案是否满足出库需求
     * @param outboundId 出库单ID
     * @return 是否满足
     */
    boolean checkAllocationSufficiency(String outboundId);

    List<WmsOutboundAllocationPlan> selectByOutboundIdAndUpdateBy(String id,String username);
}
